using Common.Commands;
using Common.Commands.AccountCommands;
using Core.Domain.Model;
using Sanelib.DataOperation;
using Sanelib.Dto;

namespace Core.Processors.AccountProcessors
{
    public class DeleteAccountProcessor : ICommandProcessor<DeleteAccount>
    {
        private readonly IRepository<Account> _accountRepository;

        public DeleteAccountProcessor(IRepository<Account> accountRepository)
        {
            _accountRepository = accountRepository;
        }

        public dynamic Process(DeleteAccount command)
        {
            var response = new WebApiResultResponse();

            var account = _accountRepository.GetById(command.Id);

            _accountRepository.Delete(account.Id);

            response.IsSuccess = true;

            return response;
        }
    }
}
